home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / HyperCuber Source / HyperCuber 2.0 Source.sit / HyperCuber 2.0 Source / CScrollNumPane.cp < prev    next >
Text File  |  1994-04-13  |  3KB  |  105 lines

  1. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. //| CScrollNumPane
  3. //|
  4. //| This implements a pane containing a number which reflects the setting of a scroll bar
  5. //|_______________________________________________________________________________________
  6.  
  7. #include "CColorPaneBorder.h"
  8. #include "CScrollNumPane.h"
  9.  
  10.  
  11. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. //| CScrollNumPane::IScrollNumPane
  13. //|
  14. //| Purpose: Initialize the scroll number pane.
  15. //|
  16. //| Parameters: scroll_bar: scroll bar to track
  17. //|             rest same as superclass
  18. //|_________________________________________________________
  19.  
  20. void CScrollNumPane::IScrollNumPane(CView *anEnclosure, CBureaucrat *aSupervisor, short aWidth,
  21.                                     short aHeight, short aHEncl, short aVEncl, SizingOption    aHSizing,
  22.                                     SizingOption aVSizing, short line, CScrollBar *scroll_bar,
  23.                                     short offset)
  24. {
  25.  
  26.     IEditText(anEnclosure, aSupervisor,                //  Call superclass' initialization routine
  27.                 aWidth, aHeight, aHEncl, aVEncl,
  28.                     aHSizing, aVSizing, line);
  29.     SetAlignCmd(cmdAlignLeft);
  30.     SetFontNumber(geneva);
  31.     SetFontSize(9);
  32.     SetWantsClicks(FALSE);                            //  No editing of this text
  33.     Specify(kNotEditable, kNotSelectable,
  34.                 kNotStylable);
  35.  
  36.     RGBColor border_color = {0xB000, 0xB000, 0xB000};
  37.     CColorPaneBorder *border =                        //  Attach a colored shadow to this pane
  38.                         new(CColorPaneBorder);
  39.     border->IColorPaneBorder(
  40.                     kBorderRight + kBorderBottom,
  41.                     &border_color);
  42.     SetBorder(border);
  43.  
  44.     num_offset = offset;                            //  Save number to add to everything
  45.  
  46.     DependUpon(scroll_bar);                            //  The number depends on the scroll bar
  47.  
  48.     ProviderChanged(scroll_bar, 0, NULL);            //  Set number to the current scroll bar value
  49.  
  50. }    //==== CScrollNumPane::IScrollNumPane() ====\\
  51.  
  52.  
  53.  
  54. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  55. //| CScrollNumPane::Draw
  56. //|
  57. //| Purpose: Draw the scroll number pane.
  58. //|
  59. //| Parameters: the_rect: rectangle to draw
  60. //|_________________________________________________________
  61.  
  62. void CScrollNumPane::Draw(Rect *the_rect)
  63. {
  64.  
  65.     Prepare();
  66.  
  67.     RGBColor back_color;                            //  Remember current background color
  68.     GetBackColor(&back_color);
  69.  
  70.     RGBColor rect_color = {0xE000, 0xE000, 0xE000};    //  Change background color
  71.     RGBBackColor(&rect_color);                        
  72.  
  73.     CEditText::Draw(the_rect);                        //  Draw the text (with colored background)
  74.  
  75.     RGBBackColor(&back_color);                        //  Restore background color
  76.  
  77. }    //==== CScrollNumPane::Draw() ====\\
  78.  
  79.  
  80.  
  81. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  82. //| CScrollNumPane::ProviderChanged
  83. //|
  84. //| Purpose: This is called every time the scroll bar moves
  85. //|
  86. //| Parameters: provider: the scroll bar
  87. //|             reason:   the reason we were called (controlValueChanged)
  88. //|             info:     unused
  89. //|_______________________________________________________________________
  90.  
  91. void CScrollNumPane::ProviderChanged(CCollaborator *provider, long reason, void *info)
  92. {
  93.  
  94.     long new_value = ((CScrollBar *) provider)->GetValue();    //  Get new number
  95.     
  96.     Str255 num_string;                                        //  Update the number in the pane
  97.     NumToString(new_value + num_offset, num_string);
  98.     SetTextPtr((char *) (num_string+1), num_string[0]);
  99.  
  100.     Rect frame_rect;
  101.     LongToQDRect(&frame, &frame_rect);
  102.     Draw(&frame_rect);
  103.  
  104. }    //==== CScrollNumPane::ProviderChanged() ====\\
  105.